package com.carl;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class Context_Delete {
    public static void main(String[] args) throws IOException {
        //创建es客户端
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.73.130", 9200, "http")));


        DeleteRequest deleteRequest = new DeleteRequest("user","1001");




        //客户端发送请求，获取响应对象
        DeleteResponse response = client.delete(deleteRequest, RequestOptions.DEFAULT);

        System.out.println("操作结果：" + response.getResult());




        client.close();
    }
}
